﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script src="/Scripts/shared/share.js" type="text/javascript"></script>
<script src="/Scripts/shared/shown.js" type="text/javascript"></script>
<div class="mini-toolbar" style="padding:2px;border-top:0;border-left:0;border-right:0;"> 
    <table style="width:100%;">
        <tr>
            <td style="width:100%;">
                <a class="mini-button" id="fresh" name="fresh" iconCls="icon-search" onclick="LoadListData" plain="true">刷新</a>
                <span class="separator"></span>
                <a class="mini-button" id="new" name="new" iconCls="icon-new" onclick="newBill" plain="true">新增</a>
                <a class="mini-button" id="save" name="save" iconCls="icon-edit" onclick="modify" plain="true">修改</a>
                <a class="mini-button" name="del" iconcls="icon-remove" onclick="delSendFull" plain="true">删除</a>
                <span class="separator"></span>
                <a class="mini-button" id="close" name="close" iconCls="icon-close" onclick="CloseWindow" plain="true">关闭</a>
            </td>
        </tr>
    </table>       
</div>
@Html.Partial("~/Views/Modular/SearchInfo.cshtml")
<div class="mini-fit">
    <div id="datagrid1" class="mini-datagrid" style="width: 100%; height: 100%;" pagesize="15"
        borderstyle="border:1;" url="/Coupon/GetSendFullList"
        allowcellselect="true" allowcelledit="true" showcolumnsmenu="true" fitcolumns="false" multiselect="true"
        onrowdblclick="modify" sortmode="client">
        <div property="columns">
            <div type="checkcolumn">选行</div>
            <div type="indexcolumn" width="40" headeralign="center">序号</div>
            <div field="FNumber" name="FNumber" width="100" headeralign="center" allowsort="true" required="true">编码</div>
            <div field="FName" name="FName" width="150" headeralign="center" allowsort="true" required="true">名称</div>
            <div field="FStartDate" name="FStartDate" width="130" headeralign="center" allowsort="true" required="true" dateFormat="yyyy-MM-dd hh:mm:ss">开始时间</div>
            <div field="FEndDate" name="FEndDate" width="130" headeralign="center" allowsort="true" dateFormat="yyyy-MM-dd hh:mm:ss">结束时间</div>
            <div field="FIsEnabled" name="FIsEnabled" width="60" headeralign="center" allowsort="true" >是否启用</div>
            <div field="FFullAmount" name="FFullAmount" width="100" headeralign="center" align="right" allowsort="true" numberformat="#,0.00">满送金额</div>
            <div field="FCouponName" name="FSendFull" width="150" headeralign="center" allowsort="true" >优惠券</div>
            <div field="FStockName" name="FStockName" width="150" headeralign="center" allowsort="true" >适用门店</div>
        </div>
    </div>
</div>
<script src="~/Scripts/common.js"></script>
<script>
    function FormShown() {

        mini.parse();
        LoadListData();
    }

    //加载资料列表
    function LoadListData() {
        var param = {
            mSystemAppID: parent.window.getSystemAppID()
        }
        var grid = mini.get("datagrid1");
        grid.load(param);
    }

    function newBill() {

        mini.open({
            url: "/Coupon/SendFullInfo",
            title: "满送详情",
            width: 900,
            height: 600,
            onload: function() {
                var iframe = this.getIFrameEl();
                var data = {
                    action: "new"
                };
                iframe.contentWindow.SetInfoData(data);
            },
            ondestroy: function(action) {
                LoadListData();
            }
        });
    }

    function modify() {
        var grid = mini.get("datagrid1");
        var row = grid.getSelected();
        if (row) {
            mini.open({
                url: "/Coupon/SendFullInfo",
                title: "满送详情",
                width: 900,
                height: 600,
                onload: function() {
                    var iframe = this.getIFrameEl();
                    var data = {
                        action: "edit",
                        FItemID: row.FItemID
                    };
                    iframe.contentWindow.SetInfoData(data);
                },
                ondestroy: function(action) {
                    LoadListData();
                }
            });

        } else {
            mini.alert("请选中一条记录");
        }
    }

    function delSendFull() {
        var grid = mini.get("datagrid1");
        var row = grid.getSelecteds();
        if (row) {
            if (confirm("确定删除？")) {
                postRequest("/Coupon/DelSendFull", { data: JSON.stringify(row) }, function(res) {
                    if (res.status == 1) {
                        LoadListData();
                        mini.showTips({ content: res.msg, state: "success", x: "center", y: "top", timeout: 3000 });
                    } else {
                        mini.showTips({ content: res.msg, state: "danger", x: "center", y: "top", timeout: 3000 });
                    }
                });
            }
        } else {
            mini.alert("请选中一条记录");
        }
    }
</script>